package com.my.security.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;

@Controller
//@RestController
@Slf4j
public class LoginController {

//    @RequestMapping("toMain")
    @PostMapping("toMain")
    public String toMain(){
        return "redirect:main.html";
    }
    @PostMapping("toError")
    public String toError(){
        return "redirect:error.html";
    }

    @PostMapping("toMain1")
//    @PreAuthorize("hasAnyRole('user')")
//    PreAuthorize == access  执行前先判断权限
//    @PreAuthorize("hasAuthority('admin')")
    //执行结束后判断权限
//    @PostAuthorize("")
    //是否有对应角色 abc
//    @Secured("ROLE_abc")
    public String toMain1(){
        return "redirect:main1.html";
    }
}
